package com.gf.framework.xxljob.config;

import com.gf.framework.xxljob.configuration.XxlJobConfigurationProperties;
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @author gaofei
 * @Description
 * @create 2022/5/23 16:14
 */
@Configuration
@Slf4j
public class XxlJobConfig  {
    @Bean
    public XxlJobSpringExecutor xxlJobExecutor(XxlJobConfigurationProperties xxlJobConfigurationProperties) {
        log.info(">>>>>>>>>>> xxl-job config init.");
        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
        xxlJobSpringExecutor.setAdminAddresses(xxlJobConfigurationProperties.getAdminAddress());
        xxlJobSpringExecutor.setAppname(xxlJobConfigurationProperties.getAppname());
        xxlJobSpringExecutor.setIp(xxlJobConfigurationProperties.getIp());
        xxlJobSpringExecutor.setPort(xxlJobConfigurationProperties.getPort());
        xxlJobSpringExecutor.setAccessToken(xxlJobConfigurationProperties.getAccessToken());
        xxlJobSpringExecutor.setLogPath(xxlJobConfigurationProperties.getLogpath());
        xxlJobSpringExecutor.setLogRetentionDays(xxlJobConfigurationProperties.getLogretentiondays());

        return xxlJobSpringExecutor;
    }
}
